package com.huatai.datacenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huatai.common.util.ObjectUtil;
import com.huatai.common.util.StringUtil;
import com.huatai.datacenter.entity.dataquality.QualityBaseEntity;
import com.huatai.datacenter.entity.dataquality.QualityLogDetailEntity;
import com.huatai.datacenter.mapper.QualityLogDetailMapper;
import com.huatai.datacenter.service.QualityLogDetailService;
import org.springframework.stereotype.Service;

/**
 * @author gusiyi
 * @version 1.0
 * @className QualityLogDetailServiceImpl
 * @description 描述：
 * @date 2023/6/6 15:28
 */
@Service
public class QualityLogDetailServiceImpl extends ServiceImpl<QualityLogDetailMapper, QualityLogDetailEntity> implements QualityLogDetailService {

	@Override
	public Page<QualityLogDetailEntity> getLogDetailList(QualityLogDetailEntity qualityLogDetailEntity) {
		LambdaQueryWrapper<QualityLogDetailEntity> logDetialQuery = Wrappers.lambdaQuery();
		logDetialQuery
			.eq(QualityBaseEntity::getDeleted,false)
			.eq(QualityLogDetailEntity::getQualityLogId,qualityLogDetailEntity.getQualityLogId())
			.eq(ObjectUtil.isNotEmpty(qualityLogDetailEntity.getQualityRuleId()),QualityLogDetailEntity::getQualityRuleId,qualityLogDetailEntity.getQualityRuleId())
			.between
				(ObjectUtil.isNotEmpty(qualityLogDetailEntity.getStartTime())&&ObjectUtil.isNotEmpty(qualityLogDetailEntity.getEndTime())
					,QualityLogDetailEntity::getCreateTime
					,qualityLogDetailEntity.getStartTime()
					,qualityLogDetailEntity.getEndTime());
		Page<QualityLogDetailEntity> page = new Page<>(qualityLogDetailEntity.getPageIndex(),qualityLogDetailEntity.getPageSize());
		return page(page,logDetialQuery);
	}
}
